+ /* Start retrieving information from the database */
+ /* Get the zoneid first */
+ gettime(&tt);
+ sprintf(dbString,"select zoneid from %s where name like '%s.%%'",zp->z_dbztable,zp->z_origin);
+ if (msqlQuery(dbNum,dbString)==-1){
+ errs++;
+ syslog(LOG_ERR,msqlErrMsg);
+ msqlClose(dbNum);
+ continue;
+ };
+ msqlData.result = msqlStoreResult();
+ /* Check validity of zone */
+ if (!(dbZone=msqlNumRows(msqlData.result))){
+ errs++;
+ syslog(LOG_ERR,"msql_dns: No zoneid associated with zone %s",zp->z_origin);
+ msqlClose(dbNum);
+ continue;
+ } else if (dbZone > 1){
+ syslog(LOG_ERR,"db_load: Multiple zoneids found for zone %s, using first one",zp->z_origin);
+ };
+ dbrow = msqlFetchRow(msqlData.result);
+ dbZone = atoi(dbrow[0]);
+ msqlFreeResult(msqlData.result);
+ /* Zone is valid, start retrieving entries */
+ sprintf(dbString,"select machine, class, type, info, importance, dynamic from %s where importance<3 or assigned_time >%d and zoneid = %d order by importance", zp->z_dbdtable,zp->z_dbtime,dbZone);
+ if (msqlQuery(dbNum,dbString)==-1){
+ errs++;
+ syslog(LOG_ERR,msqlErrMsg);
+ msqlClose(dbNum);
+ continue;
+ };
+ msqlData.result = msqlStoreResult();
+ msqlClose(dbNum);
+ msqlDataSeek(msqlData.result,0);
+ /* Check to see if anything besides SOA & NS entries were retrieved */
+ while ((dbrow=msqlFetchRow(msqlData.result))!=NULL)
+ if (atoi(dbrow[4])>2)
+ dbnew++;
+ msqlDataSeek(msqlData.result,0);
+ if (dbnew){
+ msqlData.row = 0;
+ bzero(msqlData.buffer,
+ sizeof(msqlData.buffer));
+ msqlData.linePos = 0;
+ /* Default to static entries */ msqlData.status = 0;
+ usingMsql = 1;
+ } else
+ usingMsql = 0;
+ zp->z_dbtime = tt.tv_sec;
+ if (!zp->z_dblastupdate)
+ zp->z_dblastupdate = tt.tv_sec;
+ zp->z_dbupdate = dbupdate;
+ zp->z_dbrefresh = dbrefresh;
+ break;
+ }
+ #endif /* MSQL */
+
default:
goto err;
}
***************
*** 739,744 ****
--- 891,902 ----
dp->d_flags = dataflags;
dp->d_cred = DB_C_ZONE;
dp->d_clev = clev;
+ #ifdef MSQL
+ if (usingMsql)
+ dp->d_dynamic = msqlData.status;
+ else
+ dp->d_dynamic = 0;
+ #endif
if ((c = db_update(domain, dp, dp, dbflags,
(zp->z_type == Z_CACHE)
? fcachetab
***************
*** 824,830 ****
char op[32];
for (;;) {
! c = getc(fp);
top:
switch (c) {
case EOF:
--- 982,988 ----
char op[32];
for (;;) {
! c = GETC(fp);
top:
switch (c) {
case EOF:
***************
*** 843,849 ****
return (ERROR);
case ';':
! while ((c = getc(fp)) != EOF && c != '\n')
;
goto top;
--- 1001,1007 ----
return (ERROR);
case ';':
! while ((c = GETC(fp)) != EOF && c != '\n')
;
goto top;
***************
*** 862,868 ****
continue;
default:
! (void) ungetc(c, fp);
return (DNAME);
}
}
--- 1020,1026 ----
continue;
default:
! (void) UNGETC(c, fp);
return (DNAME);
}
}
***************
*** 889,919 ****
register int c;
empty_token = 0;
! for (cp = buf; (c = getc(fp)) != EOF; ) {
if (c == ';') {
! while ((c = getc(fp)) != EOF && c != '\n')
;
c = '\n';
}
if (c == '\n') {
if (cp != buf)
! ungetc(c, fp);
else
lineno++;
break;
}
if (isspace(c)) {
! while (isspace(c = getc(fp)) && c != '\n')
;
! ungetc(c, fp);
if (cp != buf) /* Trailing whitespace */
break;
continue; /* Leading whitespace */
}
if (c == '"') {
! while ((c = getc(fp)) != EOF && c != '"' && c != '\n') {
if (c == '\\') {
! if ((c = getc(fp)) == EOF)
c = '\\';
if (c == '\n')
lineno++;
--- 1047,1077 ----
register int c;
empty_token = 0;
! for (cp = buf; (c = GETC(fp)) != EOF; ) {
if (c == ';') {
! while ((c = GETC(fp)) != EOF && c != '\n')
;
c = '\n';
}
if (c == '\n') {
if (cp != buf)
! UNGETC(c, fp);
else
lineno++;
break;
}
if (isspace(c)) {
! while (isspace(c = GETC(fp)) && c != '\n')
;
! UNGETC(c, fp);
if (cp != buf) /* Trailing whitespace */
break;
continue; /* Leading whitespace */
}
if (c == '"') {
! while ((c = GETC(fp)) != EOF && c != '"' && c != '\n') {